package com.eduask.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.xml.crypto.Data;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.eduask.model.User;
import com.eduask.service.UserService;

@Controller
@RequestMapping("first")
public class First {
	
	@Autowired
	private UserService userservice;
	
	
	@RequestMapping("loginsuccess")
	public ModelAndView loginsuccess(User user,HttpServletRequest req) {
		req.getSession().setAttribute("email", userservice.useremail(user.getUsername()));
		//shijian
		/*SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String time=df.format(System.currentTimeMillis());
		System.out.println(time);
		Date day=new Date();    
		long times = day.getTime();
		System.out.println("當前時間"+times);*/
		
		ModelAndView mo = new ModelAndView();
		mo.setViewName("emailList");
		return mo;
	}
	
	@RequestMapping("write")
	public ModelAndView write(HttpServletRequest req){
		req.setAttribute("username", req.getParameter("username"));
		ModelAndView mo = new ModelAndView();
		mo.setViewName("write");
		return mo;
	}
	
}
